<?php
//接收数据账号和密码
$name = $_POST['user_name'];
$pwd = $_POST['user_pwd'];
//连接数据库
$dbh = new PDO('mysql:host=127.0.0.1;dbname=1105', "root", "root");
//防sql注入
$name = $dbh->quote($name);
$pwd = $dbh->quote($pwd);
//查询的sql语句
$sql = "select * from user where user_name = $name and user_pwd = $pwd";
//执行sql语句
$res = $dbh->query($sql);
//判断是否登录成功
if($res){
    $arr['code'] = 0;
    $arr['msg'] = '登录成功';
    $arr['data'] = [];
}else{
    $arr['code'] = 1;
    $arr['msg'] = '登录失败';
    $arr['data'] = [];
}
//返回json格式的数据
echo json_encode($arr);
